package com.cold.demo.template.controller;

import com.cold.demo.template.pojo.Res;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.MatrixVariable;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.awt.*;

@Api("测试-矩阵变量")
@RestController
public class MatrixVariableController {


    /**
     * Spring也支持URL
     * 中的矩阵变量，所谓矩阵变量，就是出现在路径片段中，通过符号“；”
     * 分割的多个变量，比如/user/id=123 ;status= l/update.json
     */
//    @ApiIgnore("测试忽略注解")
    @ApiOperation("测试矩阵变量接口")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "400", description = "参数错误"),
            @ApiResponse(responseCode = "500", description = "服务器出错")})
    @GetMapping(value = "/owners/{ownerId}/pets/{petId}")
    public Res<Long> ju(@PathVariable @ApiParam("字段1") String ownerId,
                        @PathVariable String petId,
                        @MatrixVariable(value = "q", pathVar = "ownerId") String q1,
                        @MatrixVariable(value = "q", pathVar = "petId") String q2) {
        System.out.println("id:" + q1 + ":" + "df:" + q2);
        System.out.println("ownerId:" + ownerId + ":" + "petId:" + petId);
        System.out.println("123456789");
        return Res.success(System.currentTimeMillis());
    }


}
